package org.redmagic.agent.location.commandline;

import static org.redmagic.utils.Conditions.checkArgument;
import static org.redmagic.utils.Conditions.notNull;

import org.redmagic.agent.location.DomLocationParser;
import org.redmagic.location.Location;
import org.w3c.dom.Element;

public class CommandLineLocationParser implements DomLocationParser {

    public static final String CL_LOCATION_ELEMENT_TAG = "commandLineLocation";
    
    @Override
    public Location parse(Element locationElement) {
        // even though we don't use the locationElement, this code shouldn't be
        // called from within redmagic without one of these locationElements
        // showing up in the xml.  so this is just here for more of a sanity
        // check than anything else.  also, we want to make sure that the code
        // is only being called when its supposed to be called, aka, on a 
        // "commandLineLocation" element.
        notNull(locationElement, "locationElement");
        checkArgument(CL_LOCATION_ELEMENT_TAG.equals(locationElement.getTagName()), 
                                 "Invalid element passed in.  Expecting one with a tagName of '" + CL_LOCATION_ELEMENT_TAG + "'.");
        return new CommandLineLocation();
    }

    @Override
    public String toString() {
        return CL_LOCATION_ELEMENT_TAG + "Parser";
    }
}